﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="ManterVenda.aspx.cs" Inherits="SisVenda.Web.Vendedor.ManterVenda" %>

<%@ OutputCache Location="None" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <asp:Panel ID="aux" runat="server" Visible="true" HorizontalAlign="Right" Style="display: none">
        <input type="checkbox" id="effect_fade" checked="checked" disabled="disabled" style="display: none" /><label
            for="effect_fade"></label>
        <input type="checkbox" id="effect_collapse" disabled="disabled" style="display: none" /><label
            for="effect_collapse"></label>
        <input type="checkbox" id="effect_color" disabled="disabled" style="display: none" /><label
            for="effect_color"></label>
    </asp:Panel>
    <asp:Panel ID="pnlVenda" runat="server" GroupingText="Manter Venda">
        <asp:Panel ID="pnlColapse" runat="server" CssClass="collapsePanelHeader" Height="30px">
            <div style="padding: 5px; cursor: pointer; vertical-align: middle;">
                <div style="float: left;">
                    Painel de Pesquisa</div>
                <div style="float: left; margin-left: 20px;">
                    <asp:Label ID="Label1" runat="server">[Expandir...]</asp:Label>
                </div>
                <div style="float: right; vertical-align: middle;">
                    <asp:ImageButton ID="Image1" runat="server" ImageUrl="~/App_Themes/Tema/Images/recolher.gif"
                        AlternateText="[Mostra Detalhes...]" />
                </div>
            </div>
        </asp:Panel>
        <asp:Panel ID="pnlListagem" runat="server" DefaultButton="btnPesquisar" Style="overflow: hidden">
            <fieldset style="overflow: hidden">
                <legend>Venda</legend>
                <table class="filtros">
                    <tr>
                        <td class="rotulo">
                            Opções de Pesquisa
                            <br />
                            <asp:DropDownList ID="ddlParametroPesquisa" runat="server" SkinID="ParaemtroPesquisaVenda">
                            </asp:DropDownList>
                        </td>
                        <td class="rotulo">
                            Parâmetro de Pesquisa
                            <br />
                            <asp:TextBox ID="tbxPesquisa" runat="server" CssClass="largura450px"></asp:TextBox>
                            <act:FilteredTextBoxExtender ID="FilteredTextBoxExtenderPesquisa" runat="server"
                                TargetControlID="tbxpesquisa" FilterType="Custom, LowercaseLetters, UppercaseLetters, Numbers"
                                ValidChars=" +*/-" />
                            <act:TextBoxWatermarkExtender ID="tbwtbxPesquisa" runat="server" TargetControlID="tbxPesquisa"
                                WatermarkText="Parâmetro de pesquisa" WatermarkCssClass="watermarked" SkinID="Water440" />
                        </td>
                        <td class="rotulo">
                            Situação da venda
                            <br />
                            <asp:DropDownList ID="ddlSituaçãoVenda" runat="server" SkinID="SituacaoVenda">
                            </asp:DropDownList>
                        </td>
                        <td class="rotulo">
                            Linhas
                            <br />
                            <asp:DropDownList ID="ddlNumeroLinhasGrid" runat="server" AutoPostBack="True" SkinID="Paginacao"
                                Style="cursor: pointer;" OnSelectedIndexChanged="ddlNumeroLinhasGrid_SelectedIndexChanged">
                            </asp:DropDownList>
                        </td>
                        <td class="rotuloFiltro">
                            <br />
                            <asp:Button ID="btnPesquisar" runat="server" Text="Pesquisar" CausesValidation="False"
                                SkinID="Pesquisar" Style="cursor: pointer; height: 26px; margin-bottom: 0px;"
                                OnClick="btnPesquisar_Click" />
                        </td>
                    </tr>
                </table>
                <asp:UpdatePanel ID="uppPesquisa" runat="server">
                    <ContentTemplate>
                        <asp:GridView ID="gvwListagem" runat="server" DataKeyNames="IdVenda" SkinID="SemSelect"
                            AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" SelectedIndex="0"
                            DataSourceID="odsGridView" OnDataBinding="gvwListagem_DataBinding" OnSelectedIndexChanged="gvwListagem_SelectedIndexChanged">
                            <Columns>
                                <asp:TemplateField ShowHeader="False">
                                    <ItemStyle HorizontalAlign="Center" Width="25px" CssClass="PaddingGridView" />
                                    <HeaderStyle CssClass="PaddingGridViewHeader" />
                                    <ItemTemplate>
                                        <asp:ImageButton ID="ibnSelect" runat="server" CommandName="Select" CausesValidation="False"
                                            SkinID="Select" />
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="IdVenda" HeaderText="Cod. Venda" />
                                <asp:BoundField DataField="Cliente" HeaderText="Cliente" />
                                <asp:BoundField DataField="ValorTotal" HeaderText="Valor Total" />
                                <asp:BoundField DataField="DataVenda" HeaderText="Data" />
                                <asp:BoundField DataField="Situacao" HeaderText="Situacao" />
                                <asp:BoundField DataField="Vendedor" HeaderText="Vendedor" />
                                <asp:BoundField DataField="TotalComissao" HeaderText="Valor Comissao" />
                            </Columns>
                        </asp:GridView>
                        <asp:ObjectDataSource ID="odsGridView" runat="server" OldValuesParameterFormatString="original_{0}"
                            SelectMethod="ObterVenda" TypeName="SisVenda.Web.Vendedor.Fn.VendaFn" OnSelecting="odsGridView_Selecting">
                            <SelectParameters>
                                <asp:Parameter Name="tipoConsulta" Type="String" />
                                <asp:Parameter Name="parametroPesquisa" Type="String" />
                                <asp:Parameter Name="situacaoVenda" Type="String" />
                            </SelectParameters>
                        </asp:ObjectDataSource>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnPesquisar" EventName="Click" />
                        <asp:AsyncPostBackTrigger ControlID="ddlNumeroLinhasGrid" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
                <act:UpdatePanelAnimationExtender ID="uppaePesquisaVenda" BehaviorID="animation"
                    runat="server" TargetControlID="uppPesquisa">
                    <Animations>
                    <OnUpdating>
                    <Sequence>
                        <%-- Store the original height of the panel --%>
                        <ScriptAction Script="var b = $find('animation'); b._originalHeight = b._element.offsetHeight;" />
                        
                        <%-- Disable all the controls --%>
                        <Parallel duration="0">
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                        </Parallel>
                        <StyleAction Attribute="overflow" Value="hidden" />
                        
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeOut AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <Resize Height="0" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    EndValue="#FFFFFF" StartValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                    </Sequence>
                </OnUpdating>
                <OnUpdated>
                    <Sequence>
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeIn AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <%-- Get the stored height--%> 
                                <Resize HeightScript="$find('animation')._originalHeight" />                               
                            </Condition>
                           
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    StartValue="#FFFFFF" EndValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                        
                        <%-- Enable all the controls --%>
                        <Parallel duration="5">
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                        </Parallel>                            
                    </Sequence>
                </OnUpdated>
                    </Animations>
                </act:UpdatePanelAnimationExtender>
            </fieldset>
        </asp:Panel>
        <act:CollapsiblePanelExtender ID="cpeVenda" runat="Server" TargetControlID="pnlListagem"
            ExpandControlID="pnlColapse" CollapseControlID="pnlColapse" Collapsed="True"
            ImageControlID="Image1" TextLabelID="Label1" ExpandedText="[Ocultar Detalhes...]"
            CollapsedText="[Mostrar Detalhes...]" ExpandedImage="../App_Themes/Tema/Images/recolher.gif"
            CollapsedImage="../App_Themes/Tema/Images/expandir.gif" SuppressPostBack="true"
            SkinID="ColapsePanel" />
        <asp:UpdatePanel ID="uppVenda" runat="server">
            <ContentTemplate>
                <asp:FormView ID="fvwVenda" runat="server" DataSourceID="odsFfwVenda" OnModeChanged="fvwVenda_ModeChanged"
                    OnLoad="fvwVenda_Load">
                    <ItemTemplate>
                        <asp:Panel ID="pnlLeitura" runat="server" GroupingText="Edição">
                            <div class="divTable">
                                <div class="divLinha">
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblCodigoVendaItem" runat="server" Text="Cód. Venda"></asp:Label><br />
                                            <asp:TextBox ID="tbxCodigoVendaItem" runat="server" Text='<%# Eval("IdVenda") %>'
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblCodigoClienteItem" runat="server" Text="Cód. Cliente"></asp:Label><br />
                                            <asp:TextBox ID="tbxCodigoClienteItem" runat="server" Text='<%# Eval("idCliente") %>'
                                                Enabled="False"></asp:TextBox>
                                            <asp:Label ID="lblTipoPessoaItem" runat="server" Text='<%# Eval("TipoPessoa") %>'
                                                Visible="false"></asp:Label>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblClienteItem" runat="server" Text="Cliente"></asp:Label><br />
                                            <asp:TextBox ID="tbxClienteItem" runat="server" Text='<%# Eval("Cliente") %>' Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblCPF_CNPJItem" runat="server" Text=""></asp:Label><br />
                                            <asp:TextBox ID="tbxCPFItem" runat="server" Text='<%# Eval("CPF") %>' Visible="false"
                                                Enabled="False"></asp:TextBox>
                                            <asp:TextBox ID="tbxCNPJItem" runat="server" Text='<%# Eval("CNPJ") %>' Visible="false"
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblRG_IEItem" runat="server" Text=""></asp:Label><br />
                                            <asp:TextBox ID="tbxRGItem" runat="server" Text='<%# Eval("RG") %>' Visible="false"
                                                Enabled="False"></asp:TextBox>
                                            <asp:TextBox ID="tbxIEItem" runat="server" Text='<%# Eval("InscricaoEstadual") %>'
                                                Visible="false" Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <asp:Panel ID="pnlItemVendaItem" runat="server" GroupingText="Itens da Venda">
                                <asp:GridView ID="gvwItemVendaItem" runat="server" AllowPaging="True" AllowSorting="True"
                                    AutoGenerateColumns="False" DataKeyNames="idProduto" DataSourceID="odsGvwItemVendaItem"
                                    SelectedIndex="0" SkinID="SemSelect" Style="margin-top: 0px" OnDataBinding="gvwListagem_DataBinding"
                                    OnSelectedIndexChanged="gvwListagem_SelectedIndexChanged">
                                    <Columns>
                                        <asp:TemplateField ShowHeader="False">
                                            <ItemStyle CssClass="PaddingGridView" HorizontalAlign="Center" Width="25px" />
                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="IdProduto" HeaderText="Código" />
                                        <asp:BoundField DataField="Descricao" HeaderText="Produto" />
                                        <asp:BoundField DataField="Unidade" HeaderText="Un." />
                                        <asp:BoundField DataField="Quantidade" HeaderText="Quantidade" />
                                        <asp:BoundField DataField="Preco" HeaderText="V. Unitário" />
                                        <asp:BoundField DataField="ValorComissao" HeaderText="V. Comissão" />
                                        <asp:BoundField DataField="Valor" HeaderText="V. Total" />
                                    </Columns>
                                </asp:GridView>
                                <asp:ObjectDataSource ID="odsGvwItemVendaItem" runat="server" OnSelecting="odsGvwItemVendaItem_Selecting"
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="ObterItensVenda"
                                    TypeName="SisVenda.Web.Vendedor.Fn.VendaFn">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="gvwListagem" Name="idVenda" PropertyName="SelectedValue"
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </asp:Panel>
                            <div class="divTable">
                                <div class="divLinha">
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblCategoriaVendaItem" runat="server" Text="Categoria Venda"></asp:Label><br />
                                            <asp:TextBox ID="tbxIdCategoriaVendaItem" runat="server" Text='<%# Eval("IdCategoriaVenda") %>'
                                                Visible="false" Enabled="False"></asp:TextBox>
                                            <asp:TextBox ID="tbxCategoriaVendaItem" runat="server" Text='<%# Eval("CategoriaVenda") %>'
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblNumeroParcelaItem" runat="server" Text="Nº parcelas "></asp:Label><br />
                                            <asp:TextBox ID="tbxNumeroParcelaItem" runat="server" Text='<%# Eval("QtdParcelas") %>'
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblDescontoItem" runat="server" Text="Desconto"></asp:Label><br />
                                            <asp:TextBox ID="tbxDescontoItem" runat="server" Text="" Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblValorParcelaItem" runat="server" Text="Valor Venda"></asp:Label><br />
                                            <asp:TextBox ID="tbxValorParcelaItem" runat="server" Text='<%# Eval("ValorParcela") %>'
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblValorVendaItem" runat="server" Text="Valor Venda"></asp:Label><br />
                                            <asp:TextBox ID="tbxvalorVendaItem" runat="server" Text='<%# Eval("ValorTotal") %>'
                                                Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:CheckBoxList ID="cblEstadoVendaItem" runat="server" Visible="False">
                                                <asp:ListItem Text="Cancelar" Value="CANCELAR">CANCELAR</asp:ListItem>
                                                <asp:ListItem Text="Cancelar" Value="APROVAR">APROVAR</asp:ListItem>
                                                <asp:ListItem Text="Cancelar" Value="DESPACHAR">DESPACHAR</asp:ListItem>
                                            </asp:CheckBoxList>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Button ID="btnConfirmarEstadoVendaItem" runat="server" Text="Confirmar" Style="cursor: pointer;"
                                                Visible="False" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <asp:Panel ID="pnlParcelaItem" runat="server" GroupingText="Forma de Pagamento">
                                <asp:GridView ID="gvwParcelaItem" runat="server" AllowPaging="True" AllowSorting="True"
                                    AutoGenerateColumns="False" DataSourceID="odsParcelaItem" SelectedIndex="0" SkinID="SemSelect"
                                    Style="margin-top: 0px" OnDataBinding="gvwListagem_DataBinding" OnSelectedIndexChanged="gvwListagem_SelectedIndexChanged">
                                    <Columns>
                                        <asp:TemplateField ShowHeader="False">
                                            <ItemStyle CssClass="PaddingGridView" HorizontalAlign="Center" Width="25px" />
                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="NumeroParcela" HeaderText="Número" />
                                        <asp:BoundField DataField="ValorParcela" HeaderText="Valor" />
                                        <asp:BoundField DataField="DataVencimento" HeaderText="Data Vencimento" />
                                        <asp:BoundField DataField="ValorComissao" HeaderText="Valor Comissão" />
                                        <asp:BoundField DataField="SituacaoParcela" HeaderText="Situação" />
                                    </Columns>
                                </asp:GridView>
                                <asp:ObjectDataSource ID="odsParcelaItem" runat="server" OldValuesParameterFormatString="original_{0}"
                                    OnSelecting="odsParcelaItem_Selecting" SelectMethod="ObterFormaPagamento" TypeName="SisVenda.Web.Vendedor.Fn.VendaFn">
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="gvwListagem" Name="idVenda" PropertyName="SelectedValue"
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </asp:Panel>
                            <div class="acoes">
                                &nbsp;<asp:Button ID="btnAlterarItem" runat="server" SkinID="Alterar" CommandName="Edit"
                                    Text="Alterar" Style="cursor: pointer;" />
                                &nbsp;<asp:Button ID="btnExcluirItem" runat="server" CommandName="Delete" SkinID="Excluir"
                                    Text="Excluir" Style="cursor: pointer;" />
                                &nbsp;<asp:Button ID="btnNovoItem" runat="server" CommandName="New" SkinID="Novo"
                                    Text="Novo" Style="cursor: pointer;" />
                                <act:ConfirmButtonExtender ID="ConfirmButtonExtenderItem" runat="server" TargetControlID="btnExcluirItem"
                                    OnClientCancel="cancelClick" DisplayModalPopupID="ModalPopupExtenderItem" />
                                <br />
                                <act:ModalPopupExtender ID="ModalPopupExtenderItem" runat="server" TargetControlID="btnExcluirItem"
                                    PopupControlID="PNLItem" OkControlID="ButtonOkItem" CancelControlID="ButtonCancelItem"
                                    BackgroundCssClass="modalBackground" Enabled="True" />
                                <asp:Panel ID="PNLItem" runat="server" Style="display: none; width: 200px; background-color: White;
                                    border-width: 2px; border-color: Black; border-style: solid; padding: 20px; text-align: left;
                                    background: -webkit-gradient(linear, left top, left 56, from(#bfcbd6), color-stop(4%, #bfcbd6), to(#FFFFFF));
                                    background: -moz-linear-gradient(top, #bfcbd6, #bfcbd6 1px, #FFFFFF 50px); border-radius: 4px;
                                    -webkit-border-radius: 4px; -moz-border-radius: 4px;">
                                    <div style="text-align: right;">
                                        <img alt="?" src="../App_Themes/Tema/Images/help-icon.png" />
                                    </div>
                                    Deseja realmente excluir o registro?
                                    <br />
                                    <br />
                                    <div style="text-align: right;">
                                        <asp:Button ID="ButtonOkItem" runat="server" Text="Sim" Style="cursor: pointer;" />
                                        <asp:Button ID="ButtonCancelItem" runat="server" Text="Não" Style="cursor: pointer;" />
                                    </div>
                                </asp:Panel>
                            </div>
                        </asp:Panel>
                    </ItemTemplate>
                    <InsertItemTemplate>
                        <asp:Panel ID="pnlNovo" runat="server" GroupingText="Novo">
                            <asp:Panel ID="pnlPesquisaClienteInsert" runat="server" Style="overflow: hidden">
                                <asp:Panel ID="pnlColapseClienteInsert" runat="server" CssClass="collapsePanelHeader"
                                    Height="30px">
                                    <div style="padding: 5px; cursor: pointer; vertical-align: middle;">
                                        <div style="float: left;">
                                            Painel de Pesquisa Cliente</div>
                                        <div style="float: left; margin-left: 20px;">
                                            <asp:Label ID="lblColClienteInsert" runat="server">[Expandir...]</asp:Label>
                                        </div>
                                        <div style="float: right; vertical-align: middle;">
                                            <asp:ImageButton ID="ImageClienteInsert" runat="server" ImageUrl="~/App_Themes/Tema/Images/recolher.gif"
                                                AlternateText="[Mostra Detalhes...]" />
                                        </div>
                                    </div>
                                </asp:Panel>
                                <asp:Panel ID="pnlListagemClienteInsert" runat="server" Style="overflow: hidden">
                                    <fieldset>
                                        <legend>Pesquisa de Cliente</legend>
                                        <table class="filtros">
                                            <tr>
                                                <td class="rotulo">
                                                    <asp:Label ID="lblTipoPesquisaClienteInsert" runat="server" Text="Tipo Pesquisa"></asp:Label><br />
                                                    <asp:DropDownList ID="ddlTipoConsultaClienteInsert" runat="server" SkinID="ParaemtroPesquisaCliente">
                                                    </asp:DropDownList>
                                                </td>
                                                <td class="rotulo">
                                                    <asp:Label ID="lblParametroPesquisaClienteInsert" runat="server" Text="Parâmetro de Pesquisa"></asp:Label><br />
                                                    <asp:TextBox ID="tbxParametroConsultaClienteInsert" runat="server" CssClass="largura450px"></asp:TextBox>
                                                    <act:FilteredTextBoxExtender ID="ftbxeParametroConsultaClienteInsert" runat="server"
                                                        TargetControlID="tbxParametroConsultaClienteInsert" FilterType="Custom, LowercaseLetters, UppercaseLetters, Numbers"
                                                        ValidChars=" +*/-" />
                                                    <act:TextBoxWatermarkExtender ID="tbwtbxParametroConsultaClienteInsert" runat="server"
                                                        TargetControlID="tbxParametroConsultaClienteInsert" WatermarkText="Descrição Do Parêmtro de Pesquisa"
                                                        SkinID="Water440" />
                                                </td>
                                                <td class="rotulo">
                                                    <asp:Label ID="lblLinhas" runat="server" Text="Linhas"></asp:Label><br />
                                                    <asp:DropDownList ID="ddlNumeroLinhasGridPesquisaClienteInsert" runat="server" AutoPostBack="True"
                                                        SkinID="Paginacao" OnSelectedIndexChanged="ddlNumeroLinhasGridPesquisaClienteInsert_SelectedIndexChanged">
                                                    </asp:DropDownList>
                                                </td>
                                                <td align="right">
                                                    <br />
                                                    <asp:Button ID="btnPesquisarClienteInsert" runat="server" Text="Pesquisar" CausesValidation="False"
                                                        SkinID="Pesquisar" Style="height: 26px; margin-bottom: 0px; cursor: pointer;"
                                                        OnClick="btnPesquisarClienteInsert_Click" />
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:UpdatePanel ID="uppPesquisaClienteInsert" runat="server">
                                            <ContentTemplate>
                                                <asp:GridView ID="gvwListagemClienteInsert" runat="server" AllowPaging="True" DataKeyNames="idCliente"
                                                    SkinID="SemSelect" AllowSorting="True" SelectedIndex="0" Style="margin-top: 0px"
                                                    DataSourceID="odsGvwListagemClienteInsert" OnDataBinding="gvwListagemClienteInsert_DataBinding"
                                                    AutoGenerateColumns="False" OnSelectedIndexChanged="gvwListagemClienteInsert_SelectedIndexChanged">
                                                    <Columns>
                                                        <asp:TemplateField ShowHeader="False">
                                                            <ItemStyle HorizontalAlign="Center" Width="25px" CssClass="PaddingGridView" />
                                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                                            <ItemTemplate>
                                                                <asp:ImageButton ID="ibnSelect" runat="server" CommandName="Select" CausesValidation="False"
                                                                    SkinID="Select" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="IdCliente" HeaderText="Cód. Cliente" />
                                                        <asp:BoundField DataField="Cliente" HeaderText="Cliente" />
                                                        <asp:BoundField DataField="CPF" HeaderText="CPF" />
                                                        <asp:BoundField DataField="CNPJ" HeaderText="CNPJ" />
                                                        <asp:BoundField DataField="Tipo" HeaderText="Tipo" />
                                                        <asp:BoundField DataField="Telefone" HeaderText="Telefone" />
                                                        <asp:BoundField DataField="Celular" HeaderText="Celular" />
                                                    </Columns>
                                                </asp:GridView>
                                                <asp:ObjectDataSource ID="odsGvwListagemClienteInsert" runat="server" OldValuesParameterFormatString="original_{0}"
                                                    SelectMethod="ObterCliente" TypeName="SisVenda.Web.Restrito.Fn.ManterClienteFn"
                                                    OnSelecting="odsGvwListagemClienteInsert_Selecting">
                                                    <SelectParameters>
                                                        <asp:Parameter Name="tipoConsulta" Type="String" />
                                                        <asp:Parameter Name="parametroPesquisa" Type="String" />
                                                    </SelectParameters>
                                                </asp:ObjectDataSource>
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="btnPesquisarClienteInsert" EventName="Click" />
                                                <asp:AsyncPostBackTrigger ControlID="ddlNumeroLinhasGridPesquisaClienteInsert" EventName="SelectedIndexChanged" />
                                            </Triggers>
                                        </asp:UpdatePanel>
                                        <act:UpdatePanelAnimationExtender ID="uppaePesquisaClienteInsert" BehaviorID="animation"
                                            runat="server" TargetControlID="uppPesquisaClienteInsert">
                                            <Animations>
                    <OnUpdating>
                    <Sequence>
                        <%-- Store the original height of the panel --%>
                        <ScriptAction Script="var b = $find('animation'); b._originalHeight = b._element.offsetHeight;" />
                        
                        <%-- Disable all the controls --%>
                        <Parallel duration="0">
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                        </Parallel>
                        <StyleAction Attribute="overflow" Value="hidden" />
                        
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeOut AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <Resize Height="0" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    EndValue="#FFFFFF" StartValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                    </Sequence>
                </OnUpdating>
                <OnUpdated>
                    <Sequence>
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeIn AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <%-- Get the stored height--%> 
                                <Resize HeightScript="$find('animation')._originalHeight" />                               
                            </Condition>
                           
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    StartValue="#FFFFFF" EndValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                        
                        <%-- Enable all the controls --%>
                        <Parallel duration="5">
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                        </Parallel>                            
                    </Sequence>
                </OnUpdated>
                                            </Animations>
                                        </act:UpdatePanelAnimationExtender>
                                    </fieldset>
                                </asp:Panel>
                                <act:CollapsiblePanelExtender ID="cpeClienteInsert" runat="Server" CollapseControlID="pnlColapseClienteInsert"
                                    Collapsed="True" CollapsedImage="../App_Themes/Tema/Images/expandir.gif" CollapsedText="[Mostrar Detalhes...]"
                                    ExpandControlID="pnlColapseClienteInsert" ExpandedImage="../App_Themes/Tema/Images/recolher.gif"
                                    ExpandedText="[Ocultar Detalhes...]" ImageControlID="ImageClienteInsert" SkinID="ColapsePanel"
                                    SuppressPostBack="true" TargetControlID="pnlListagemClienteInsert" TextLabelID="lblColClienteInsert" />
                            </asp:Panel>
                            <div class="divTable">
                                <div class="divLinha">
                                    <div class="divConteudo">
                                        <asp:Label ID="lblCódigoVendaInsert" runat="server" Text="Cód. Venda"></asp:Label><br />
                                        <asp:TextBox ID="tbxCodigoVendaInsert" runat="server" Enabled="False"></asp:TextBox>
                                    </div>
                                    <div class="divConteudo">
                                        <asp:Label ID="lblCodigoClienteInsert" runat="server" Text="Cód. Cliente"></asp:Label><br />
                                        <asp:TextBox ID="tbxCodigoClienteInsert" runat="server" Text='<%# Bind("idProduto") %>'
                                            Enabled="False"></asp:TextBox>
                                    </div>
                                    <div class="divConteudo">
                                        <asp:Label ID="lblClienteInsert" runat="server" Text="Cliente"></asp:Label><br />
                                        <asp:TextBox ID="tbxClienteInsert" runat="server" Text='<%# Bind("cliente") %>' Enabled="False"></asp:TextBox>
                                    </div>
                                    <div class="divConteudo">
                                        <asp:Label ID="lblCPF_CNPJInsert" runat="server" Text=""></asp:Label><br />
                                        <asp:TextBox ID="tbxCPF_CNPJInsert" runat="server" Text='<%# Bind("CPF_CNPJ") %>'
                                            Enabled="False"></asp:TextBox>
                                    </div>
                                    <div class="divConteudo">
                                        <br />
                                        <asp:Button ID="btnConfirmarClienteInsert" runat="server" Text="Confirmar" OnClick="btnConfirmarClienteInsert_Click" />
                                        <act:ConfirmButtonExtender ID="cbeClienteConfirmaInsert" runat="server" TargetControlID="btnConfirmarClienteInsert"
                                            OnClientCancel="cancelClick" DisplayModalPopupID="mpeClienteConfirmaInsert" />
                                        <act:ModalPopupExtender ID="mpeClienteConfirmaInsert" runat="server" TargetControlID="btnConfirmarClienteInsert"
                                            PopupControlID="pnlClienteConfirmaInsert" OkControlID="ButtonOkClienteConfirmaInsert"
                                            CancelControlID="ButtonCancelClienteConfirmaInsert" BackgroundCssClass="modalBackground"
                                            Enabled="True" />
                                        <asp:Panel ID="pnlClienteConfirmaInsert" runat="server" Style="display: none; width: 200px;
                                            background-color: White; border-width: 2px; border-color: Black; border-style: solid;
                                            padding: 20px; text-align: left; background: -webkit-gradient(linear, left top, left 56, from(#bfcbd6), color-stop(4%, #bfcbd6), to(#FFFFFF));
                                            background: -moz-linear-gradient(top, #bfcbd6, #bfcbd6 1px, #FFFFFF 50px); border-radius: 4px;
                                            -webkit-border-radius: 4px; -moz-border-radius: 4px;">
                                            <div style="text-align: right;">
                                                <img alt="?" src="../App_Themes/Tema/Images/help-icon.png" />
                                            </div>
                                            Depois de confirmado o cliente, não será possível alterar o cliente nesta página.
                                            <br />
                                            Confirma a operação?
                                            <br />
                                            <br />
                                            <div style="text-align: right;">
                                                <asp:Button ID="ButtonOkClienteConfirmaInsert" runat="server" Text="Sim" Style="cursor: pointer;" />
                                                <asp:Button ID="ButtonCancelClienteConfirmaInsert" runat="server" Text="Não" Style="cursor: pointer;" />
                                            </div>
                                        </asp:Panel>
                                    </div>
                                </div>
                            </div>
                            <asp:Panel ID="pnlPesquisaProdutoInsert" runat="server" Style="overflow: hidden">
                                <asp:Panel ID="pnlColapseProdutoInsert" runat="server" CssClass="collapsePanelHeader"
                                    Height="30px">
                                    <div style="padding: 5px; cursor: pointer; vertical-align: middle;">
                                        <div style="float: left;">
                                            Produto</div>
                                        <div style="float: left; margin-left: 20px;">
                                            <asp:Label ID="lblExpandirProdutoInsert" runat="server">[Expandir...]</asp:Label>
                                        </div>
                                        <div style="float: right; vertical-align: middle;">
                                            <asp:ImageButton ID="ImageButtonProdutoInsert" runat="server" ImageUrl="~/App_Themes/Tema/Images/recolher.gif"
                                                AlternateText="[Mostra Detalhes...]" />
                                        </div>
                                    </div>
                                </asp:Panel>
                                <asp:Panel ID="pnlListagemProdutosInsert" runat="server" Style="overflow: hidden">
                                    <fieldset>
                                        <legend>Pesquisa de Produtos</legend>
                                        <table class="filtros">
                                            <tr>
                                                <td>
                                                    <asp:Label ID="lblPesquisaProdutoInsert" runat="server" Text="Descrição"></asp:Label><br />
                                                    <asp:TextBox ID="tbxParametroConsultaProdutoInsert" runat="server" CssClass="largura450px"></asp:TextBox>
                                                    <act:FilteredTextBoxExtender ID="fteParametroConsultaProdutoInsert" runat="server"
                                                        TargetControlID="tbxParametroConsultaProdutoInsert" FilterType="Custom, LowercaseLetters, UppercaseLetters, Numbers"
                                                        ValidChars=" +*/-" />
                                                    <act:TextBoxWatermarkExtender ID="tbwtbxParametroConsultaProdutoInsert" runat="server"
                                                        TargetControlID="tbxParametroConsultaProdutoInsert" WatermarkText="Descrição Do Produto Para Pesquisa"
                                                        SkinID="Water440" />
                                                    <act:AutoCompleteExtender runat="server" BehaviorID="AutoCompleteEx" ID="autoCompleteProdutoInsert"
                                                        TargetControlID="tbxParametroConsultaProdutoInsert" ServicePath="AutoCompleteProduto.asmx"
                                                        ServiceMethod="GetCompletionList" SkinID="AutoComplete">
                                                        <Animations>
                                <OnShow>
                                    <Sequence>
                                        <%-- Make the completion list transparent and then show it --%>
                                        <OpacityAction Opacity="0" />
                                        <HideAction Visible="true" />
                            
                                        <%--Cache the original size of the completion list the first time
                                            the animation is played and then set it to zero --%>
                                        <ScriptAction Script="
                                            // Cache the size and setup the initial size
                                            var behavior = $find('AutoCompleteEx');
                                            if (!behavior._height) {
                                            var target = behavior.get_completionList();
                                            behavior._height = target.offsetHeight - 2;
                                            target.style.height = '0px';}" />
                            
                                        <%-- Expand from 0px to the appropriate size while fading in --%>
                                        <Parallel Duration=".4">
                                            <FadeIn />
                                            <Length PropertyKey="height" StartValue="0" EndValueScript="$find('AutoCompleteEx')._height" />
                                        </Parallel>
                                    </Sequence>
                                </OnShow>
                            <OnHide>
                                <%-- Collapse down to 0px and fade out --%>
                                <Parallel Duration=".4">
                                    <FadeOut />
                                    <Length PropertyKey="height" StartValueScript="$find('AutoCompleteEx')._height" EndValue="0" />
                                </Parallel>
                            </OnHide>
                                                        </Animations>
                                                    </act:AutoCompleteExtender>
                                                    <script type="text/javascript">
                                                        // Work around browser behavior of "auto-submitting" simple forms
                                                        var frm = document.getElementById("aspnetForm");
                                                        if (frm) {
                                                            frm.onsubmit = function () { return false; };
                                                        }
                                                    </script>
                                                    <%-- Prevent enter in textbox from causing the collapsible panel from operating --%>
                                                    <input type="submit" style="display: none;" />
                                                </td>
                                                <td>
                                                    <asp:Label ID="lblLinhasProdutoInsert" runat="server" Text="Linhas"></asp:Label>
                                                    <br />
                                                    <asp:DropDownList ID="ddlNumeroLinhasGridProdutoInsert" runat="server" AutoPostBack="True"
                                                        SkinID="Paginacao">
                                                    </asp:DropDownList>
                                                </td>
                                                <td align="right">
                                                    <br />
                                                    <asp:Button ID="btnPesquisarProdutoInsert" runat="server" Text="Pesquisar" CausesValidation="False"
                                                        SkinID="Pesquisar" Style="height: 26px; margin-bottom: 0px; cursor: pointer;"
                                                        OnClick="btnPesquisarProdutoInsert_Click" />
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:UpdatePanel ID="uppProdutoInsert" runat="server">
                                            <ContentTemplate>
                                                <asp:GridView ID="gvwListagemProdutoInsert" runat="server" DataSourceID="odsGridViewProdutoInsert"
                                                    AllowPaging="True" DataKeyNames="idProduto" AutoGenerateColumns="False" SkinID="SemSelect"
                                                    AllowSorting="True" SelectedIndex="0" Style="margin-top: 0px" OnSelectedIndexChanged="gvwListagemProdutoInsert_SelectedIndexChanged">
                                                    <Columns>
                                                        <asp:TemplateField ShowHeader="False">
                                                            <ItemStyle HorizontalAlign="Center" Width="25px" CssClass="PaddingGridView" />
                                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                                            <ItemTemplate>
                                                                <asp:ImageButton ID="ibnSelect" runat="server" CommandName="Select" CausesValidation="False"
                                                                    SkinID="Select" />
                                                            </ItemTemplate>
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="idProduto" HeaderText="Código" />
                                                        <asp:BoundField DataField="descricao" HeaderText="Descricao" />
                                                        <asp:BoundField DataField="unidade" HeaderText="Unidade" />
                                                        <asp:BoundField DataField="preco" HeaderText="Preço" />
                                                        <asp:BoundField DataField="estoque" HeaderText="Estoque" />
                                                        <asp:BoundField DataField="estoqueMinimo" HeaderText="Estoque Minimo" />
                                                        <asp:BoundField DataField="nome" HeaderText="Fornecedor" />
                                                    </Columns>
                                                </asp:GridView>
                                                <asp:ObjectDataSource ID="odsGridViewProdutoInsert" runat="server" OldValuesParameterFormatString="original_{0}"
                                                    SelectMethod="ObterProdutoCatFor" TypeName="SisVenda.Web.Restrito.Fn.CadastroProdutoFn">
                                                    <SelectParameters>
                                                        <asp:Parameter Name="descricao" Type="String" />
                                                    </SelectParameters>
                                                </asp:ObjectDataSource>
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="btnPesquisarProdutoInsert" EventName="Click" />
                                                <asp:AsyncPostBackTrigger ControlID="ddlNumeroLinhasGridProdutoInsert" EventName="SelectedIndexChanged" />
                                            </Triggers>
                                        </asp:UpdatePanel>
                                        <act:UpdatePanelAnimationExtender ID="uppaeProdutoInsert" BehaviorID="animation"
                                            runat="server" TargetControlID="uppProdutoInsert">
                                            <Animations>
                    <OnUpdating>
                    <Sequence>
                        <%-- Store the original height of the panel --%>
                        <ScriptAction Script="var b = $find('animation'); b._originalHeight = b._element.offsetHeight;" />
                        
                        <%-- Disable all the controls --%>
                        <Parallel duration="0">
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                        </Parallel>
                        <StyleAction Attribute="overflow" Value="hidden" />
                        
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeOut AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <Resize Height="0" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    EndValue="#FFFFFF" StartValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                    </Sequence>
                </OnUpdating>
                <OnUpdated>
                    <Sequence>
                        <%-- Do each of the selected effects --%>
                        <Parallel duration=".25" Fps="30">
                            <Condition ConditionScript="$get('effect_fade').checked">
                                <FadeIn AnimationTarget="up_container" minimumOpacity=".2" />
                            </Condition>
                            <Condition ConditionScript="$get('effect_collapse').checked">
                                <%-- Get the stored height--%> 
                                <Resize HeightScript="$find('animation')._originalHeight" />                               
                            </Condition>
                           
                            <Condition ConditionScript="$get('effect_color').checked">
                                <Color AnimationTarget="up_container" PropertyKey="backgroundColor"
                                    StartValue="#FFFFFF" EndValue="#FFFFFF" />
                            </Condition>
                        </Parallel>
                        
                        <%-- Enable all the controls --%>
                        <Parallel duration="5">
                            <EnableAction AnimationTarget="effect_fade" Enabled="false" />
                            <EnableAction AnimationTarget="effect_collapse" Enabled="false" />
                            <EnableAction AnimationTarget="effect_color" Enabled="false" />
                        </Parallel>                            
                    </Sequence>
                </OnUpdated>
                                            </Animations>
                                        </act:UpdatePanelAnimationExtender>
                                    </fieldset>
                                </asp:Panel>
                                <act:CollapsiblePanelExtender ID="cpeProdutoInsert" runat="Server" TargetControlID="pnlListagemProdutosInsert"
                                    ExpandControlID="pnlColapseProdutoInsert" CollapseControlID="pnlColapseProdutoInsert"
                                    Collapsed="True" ImageControlID="ImageButtonProdutoInsert" TextLabelID="lblExpandirProdutoInsert"
                                    ExpandedText="[Ocultar Detalhes...]" CollapsedText="[Mostrar Detalhes...]" ExpandedImage="../App_Themes/Tema/Images/recolher.gif"
                                    CollapsedImage="../App_Themes/Tema/Images/expandir.gif" SuppressPostBack="true"
                                    SkinID="ColapsePanel" />
                                <div class="divTable">
                                    <div class="divLinha">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblCodigoProdutoInsert" runat="server" Text="Cod. Produto"></asp:Label><br />
                                            <asp:TextBox ID="tbxCodigoProdutoInsert" runat="server" Enabled="False"></asp:TextBox>
                                        </div>
                                        <div class="divConteudo">
                                            <asp:Label ID="lblProdutoInsert" runat="server" Text="Produto"></asp:Label><br />
                                            <asp:TextBox ID="tbxProdutoInsert" runat="server" Enabled="False"></asp:TextBox>
                                        </div>
                                        <div class="divConteudo">
                                            <asp:Label ID="lblUnidadeInsert" runat="server" Text="Unidade"></asp:Label><br />
                                            <asp:TextBox ID="tbxUnidadeInsert" runat="server" EnableTheming="False" Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divLinha">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblQuantidadeInsert" runat="server" Text="Quantidade"></asp:Label><br />
                                            <asp:TextBox ID="tbxQuantidadeInsert" runat="server" AutoPostBack="True" OnTextChanged="tbxQuantidadeInsert_TextChanged"></asp:TextBox>
                                        </div>
                                        <div class="divConteudo">
                                            <asp:Label ID="lblPrecoInsert" runat="server" Text="Preço"></asp:Label><br />
                                            <asp:TextBox ID="tbxPrecoInsert" runat="server" Enabled="False"></asp:TextBox>
                                        </div>
                                        <div class="divConteudo">
                                            <asp:Label ID="lblValorTotal" runat="server" Text="V. Total"></asp:Label><br />
                                            <asp:TextBox ID="tbxValorTotalInsert" runat="server" Enabled="False">0.00</asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="acoes">
                                        <br />
                                        <asp:Button ID="btnIncluirItemInsert" runat="server" CausesValidation="False" SkinID="Inserir"
                                            Style="cursor: pointer;" Text="Incluir" OnClick="btnIncluirItemInsert_Click" />
                                        <asp:Button ID="btnLimparItemInsert" runat="server" CausesValidation="False" Style="cursor: pointer;"
                                            Text="Limpar" OnClick="btnLimparItemInsert_Click" />
                                    </div>
                                    <br />
                                </div>
                            </asp:Panel>
                            <asp:Panel ID="pnlItemVendaInsert" runat="server" GroupingText="Item de Venda">
                                <asp:GridView ID="gvwItemVendaInsert" runat="server" AllowPaging="True" AllowSorting="True"
                                    AutoGenerateColumns="False" DataKeyNames="IdProduto" SkinID="SemSelect" DataSourceID="odsGridViewItemVendaInsert"
                                    OnRowCommand="gvwItemVendaInsert_RowCommand">
                                    <Columns>
                                        <asp:TemplateField ShowHeader="False">
                                            <ItemStyle CssClass="PaddingGridView" HorizontalAlign="Center" Width="25px" />
                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                            <ItemTemplate>
                                                <asp:ImageButton ID="ibnExcluirItemVendaInsert" runat="server" CommandArgument='<%# Bind("IdProduto") %>'
                                                    CommandName="Excluir" SkinID="AcaoExcluir" />
                                                <act:ConfirmButtonExtender ID="ibnExcluirItemVendaInsert_ConfirmButtonExtender" runat="server"
                                                    Enabled="True" SkinID="Excluir" TargetControlID="ibnExcluirItemVendaInsert">
                                                </act:ConfirmButtonExtender>
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="IdProduto" HeaderText="Cód. Produto" />
                                        <asp:BoundField DataField="Descricao" HeaderText="Produto" />
                                        <asp:BoundField DataField="Unidade" HeaderText="Un." />
                                        <asp:BoundField DataField="Quantidade" HeaderText="Quant." />
                                        <asp:BoundField DataField="Preco" HeaderText="Preço" />
                                        <asp:BoundField DataField="ValorComissao" HeaderText="V. Comissão" />
                                        <asp:BoundField DataField="Valor" HeaderText="Valor" />
                                    </Columns>
                                </asp:GridView>
                                <asp:ObjectDataSource ID="odsGridViewItemVendaInsert" runat="server" DeleteMethod="DeleteItemVenda"
                                    OldValuesParameterFormatString="original_{0}" SelectMethod="ObterItensVenda"
                                    TypeName="SisVenda.Web.Vendedor.Fn.VendaFn" OnSelecting="odsGridViewItemVendaInsert_Selecting">
                                    <DeleteParameters>
                                        <asp:Parameter Name="idVenda" Type="Int32" />
                                        <asp:Parameter Name="idProduto" Type="Int32" />
                                    </DeleteParameters>
                                    <SelectParameters>
                                        <asp:ControlParameter ControlID="tbxCodigoVendaInsert" Name="idVenda" PropertyName="Text"
                                            Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </asp:Panel>
                            <div class="divTable">
                                <div class="divLinha">
                                    <div class="divConteudo">
                                        <asp:Label ID="lblCategoriaVendaInsert" runat="server" Text="Categoria Venda"></asp:Label><br />
                                        <asp:DropDownList ID="ddlcategoriaVendaInsert" runat="server" DataSourceID="odsCategoriaVendaInsert"
                                            DataTextField="Descricao" DataValueField="IdCategoriaVenda" AutoPostBack="True"
                                            OnSelectedIndexChanged="ddlcategoriaVendaInsert_SelectedIndexChanged">
                                        </asp:DropDownList>
                                        <asp:ObjectDataSource ID="odsCategoriaVendaInsert" runat="server" OldValuesParameterFormatString="original_{0}"
                                            SelectMethod="ObterCategoriaVenda" TypeName="SisVenda.Web.Administrador.Fn.CadastroCategoriaVendaFn">
                                            <SelectParameters>
                                                <asp:Parameter Name="descricao" Type="String" />
                                            </SelectParameters>
                                        </asp:ObjectDataSource>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblNumeroParcelaInsert" runat="server" Text="Nº parcelas "></asp:Label><br />
                                            <asp:DropDownList ID="ddlNumeroparcelasInsert" runat="server" AutoPostBack="True"
                                                OnSelectedIndexChanged="ddlNumeroparcelasInsert_SelectedIndexChanged">
                                                <asp:ListItem Selected="True">1</asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblValorParcelaInsert" runat="server" Text="Valor Parcela"></asp:Label><br />
                                            <asp:TextBox ID="tbxValorParcelaInsert" runat="server" Enabled="false"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblDescontoInsert" runat="server" Text="Desconto"></asp:Label><br />
                                            <asp:TextBox ID="tbxDescontoInsert" runat="server"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <asp:Label ID="lblValorVendaInsert" runat="server" Text="Valor Venda"></asp:Label><br />
                                            <asp:TextBox ID="tbxvalorVendaInsert" runat="server" Enabled="False"></asp:TextBox>
                                        </div>
                                    </div>
                                    <div class="divCell">
                                        <div class="divConteudo">
                                            <br />
                                            <asp:Button ID="bntConfirmarFormaPagamentoInsert" runat="server" Text="Confirmar"
                                                OnClick="bntConfirmarFormaPagamentoInsert_Click" />
                                            <act:ConfirmButtonExtender ID="cbeParcelaConfirmaInsert" runat="server" TargetControlID="bntConfirmarFormaPagamentoInsert"
                                                OnClientCancel="cancelClick" DisplayModalPopupID="ModalPopupExtenderConfirmaParcelaInsert" />
                                            <act:ModalPopupExtender ID="ModalPopupExtenderConfirmaParcelaInsert" runat="server"
                                                TargetControlID="bntConfirmarFormaPagamentoInsert" PopupControlID="pnlConfirmaParcelaInsert"
                                                OkControlID="ButtonOkConfirmaParcelaInsert" CancelControlID="ButtonCancelConfirmaParcelaInsert"
                                                BackgroundCssClass="modalBackground" Enabled="True" />
                                            <asp:Panel ID="pnlConfirmaParcelaInsert" runat="server" Style="display: none; width: 200px;
                                                background-color: White; border-width: 2px; border-color: Black; border-style: solid;
                                                padding: 20px; text-align: left; background: -webkit-gradient(linear, left top, left 56, from(#bfcbd6), color-stop(4%, #bfcbd6), to(#FFFFFF));
                                                background: -moz-linear-gradient(top, #bfcbd6, #bfcbd6 1px, #FFFFFF 50px); border-radius: 4px;
                                                -webkit-border-radius: 4px; -moz-border-radius: 4px;">
                                                <div style="text-align: right;">
                                                    <img alt="?" src="../App_Themes/Tema/Images/help-icon.png" />
                                                </div>
                                                Depois de confirmado a forma de pagamento, não será possível adicionar mais itens
                                                a venda, nesta página.
                                                <br />
                                                Confirma a operação?
                                                <br />
                                                <br />
                                                <div style="text-align: right;">
                                                    <asp:Button ID="ButtonOkConfirmaParcelaInsert" runat="server" Text="Sim" Style="cursor: pointer;" />
                                                    <asp:Button ID="ButtonCancelConfirmaParcelaInsert" runat="server" Text="Não" Style="cursor: pointer;" />
                                                </div>
                                            </asp:Panel>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <asp:Panel ID="pnlParcelaInsert" runat="server" GroupingText="Forma de Pagamento">
                                <asp:GridView ID="gvwParcelaInsert" runat="server" AllowPaging="True" AllowSorting="True"
                                    AutoGenerateColumns="False" DataKeyNames="" DataSourceID="odsParcelaInsert" SelectedIndex="0"
                                    SkinID="SemSelect" Style="margin-top: 0px">
                                    <Columns>
                                        <asp:TemplateField ShowHeader="False">
                                            <ItemStyle CssClass="PaddingGridView" HorizontalAlign="Center" Width="25px" />
                                            <HeaderStyle CssClass="PaddingGridViewHeader" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="NumeroParcela" HeaderText="Número" />
                                        <asp:BoundField DataField="ValorParcela" HeaderText="Valor" />
                                        <asp:BoundField DataField="DataVencimento" HeaderText="Data Vencimento" />
                                        <asp:BoundField DataField="ValorComissao" HeaderText="Valor Comissão" />
                                        <asp:BoundField DataField="SituacaoParcela" HeaderText="Situação" />
                                    </Columns>
                                </asp:GridView>
                                <asp:ObjectDataSource ID="odsParcelaInsert" runat="server" OldValuesParameterFormatString="original_{0}"
                                    OnSelecting="odsParcelaInsert_Selecting" SelectMethod="ObterFormaPagamento" TypeName="SisVenda.Web.Vendedor.Fn.VendaFn">
                                    <SelectParameters>
                                        <asp:Parameter Name="idVenda" Type="Int32" />
                                    </SelectParameters>
                                </asp:ObjectDataSource>
                            </asp:Panel>
                            <div class="acoes">
                                <asp:Button ID="btnFinalizarInsert" runat="server" CommandName="Cancel" Text="Finalizar"
                                    Visible="false" />
                                <br />
                                <act:ConfirmButtonExtender ID="ConfirmButtonExtenderInsert" runat="server" DisplayModalPopupID="ModalPopupExtenderInsert"
                                    OnClientCancel="cancelClick" TargetControlID="btnFinalizarInsert" />
                                <br />
                                <act:ModalPopupExtender ID="ModalPopupExtenderInsert" runat="server" BackgroundCssClass="modalBackground"
                                    CancelControlID="ButtonCancelInsert" OkControlID="ButtonOkInsert" PopupControlID="PNLInsert"
                                    TargetControlID="btnFinalizarInsert" />
                                <asp:Panel ID="PNLInsert" runat="server" Style="display: none; width: 200px; background-color: White;
                                    border-width: 2px; border-color: Black; border-style: solid; padding: 20px; text-align: left;
                                    background: -webkit-gradient(linear, left top, left 560, from(#bfcbd6), color-stop(4%, #bfcbd6), to(#FFFFFF));
                                    background: -moz-linear-gradient(top, #bfcbd6, #bfcbd6 1px, #FFFFFF 50px); border-radius: 4px;
                                    -webkit-border-radius: 4px; -moz-border-radius: 4px">
                                    <div style="text-align: right;">
                                        <img alt="?" src="../App_Themes/Tema/Images/help-icon.png" />
                                    </div>
                                    Os valores informados até o momento foram salvos.<br />
                                    Confirma a finalização da operação?
                                    <br />
                                    <div style="text-align: right;">
                                        <asp:Button ID="ButtonOkInsert" runat="server" Style="cursor: pointer;" Text="Sim" />
                                        <asp:Button ID="ButtonCancelInsert" runat="server" Style="cursor: pointer;" Text="Não" />
                                    </div>
                                </asp:Panel>
                            </div>
                        </asp:Panel>
                    </InsertItemTemplate>
                </asp:FormView>
                <asp:ObjectDataSource ID="odsFfwVenda" runat="server" OldValuesParameterFormatString="original_{0}"
                    OnSelecting="odsFfwVenda_Selecting" SelectMethod="obterVendaID" TypeName="SisVenda.Web.Vendedor.Fn.VendaFn">
                    <SelectParameters>
                        <asp:Parameter Name="idVenda" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="ddlNumeroLinhasGrid" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="gvwListagem" EventName="SelectedIndexChanged" />
                <asp:AsyncPostBackTrigger ControlID="btnPesquisar" EventName="Click" />
            </Triggers>
        </asp:UpdatePanel>
    </asp:Panel>
</asp:Content>
